<?php

namespace interface\v1;
/*
*考试接口类
*/

class paperManagerAppClass extends index
{
    private const page = 'paperManagement';
    private const tableMx = 'paper_library_detail';
    private const table = 'paper_library';
    private const title = '试卷管理';
    public array $itemWord = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'L'];
    public array $sortOption = ['考试时间降序','考试时间升序','创建时间降序','创建时间升序'];

    /*查询条件*/
    public function search()
    {
        //状态
        $data['sortOption'] = $this->sortOption;
        $data['defualtSort'] = 0;
        $data['stateOption'] = ["合格","不合格"];
        $data['timeOption'] = $this->timeOption;
        //返回
        $this->code = 1;
        $this->resp['data'] = $data;
    }
    /**
     * 判断回答是否正确
     * @param array $array 试题信息
     * @param array $reply 回答
     * @return bool
     */
    public function judgeAnswer(array $array, array $reply): bool
    {
        $itemArr = json_decode($array['item'], true);
        $answer = json_decode($array['answer'], true);
        $answerOrderNo = [];
        foreach ($itemArr as $k => $val) {
            if ($array['topicType'] == '单选题' && $answer[0] == $k) {
                $answerOrderNo[] = $k;
                break;
            } elseif ($array['topicType'] == '多选题' && in_array($k, $answer)) {
                $answerOrderNo[] = $k;
            } elseif ($array['topicType'] == '判断题' && $answer[0] == $k) {
                $answerOrderNo[] = $k;
                break;
            }
        }
        $isRight = false;//回答是否正确
        if ((!empty($reply) && in_array($reply[0], $answerOrderNo) && in_array($array['topicType'], ['单选题', '判断题'])) || ($reply == $answerOrderNo && $array['topicType'] === '多选题')) {
            $isRight = true;
        }
        return $isRight;
    }

    /**
     * 添加或更新答题记录
     * @param $paper
     * @param $topic
     * @param $reply
     * @param $topicAnswerRecord
     * @param $stid
     * @return bool|string
     */
    public function setAnswer($paper, $topic, $reply, $topicAnswerRecord, $stid): bool|string
    {

        if ($reply === '' || $reply === null) {
            $reply = [];
        } elseif (in_array($topic['topicType'], ['单选题', '判断题','主观题'])) {
            //重新组装回答形式，便于后面判断回答
            $reply = [$reply];
        }
        //当前试题分数
        $paperLibraryMx = query('paper_library_detail', " orderId = '$paper[id]' and topicLibraryMxId = '$topic[id]'");
        //判断当前回答是否正确
        $bool = $this->judgeAnswer($topic, $reply);
        //答题明细
        $record = query('topic_answer_record_detail', " stid = '$stid' and paperId = '$paper[id]' and topicLibraryMxId = '$topic[id]'");
        if (empty($record['id'])) {
            //没有答题记录
            $json['warn'] = insert(
                array(
                    'table' => 'topic_answer_record_detail',
                    'field' => [
                        'id' => self::getId(),
                        'orderId' => $topicAnswerRecord['id'],
                        'paperId' => $paper['id'],
                        'topicLibraryMxId' => $topic['id'],
                        'topicLibraryId' => $topic['orderId'],
                        'stid' => $stid,
                        'state' => $bool ? 1 : 2,
                        'score' => $bool ? $paperLibraryMx['score'] : 0,
                        'reply' => json_encode($reply, 320),
                        'updateTime' => $this->time,
                        'time' => $this->time,
                    ]
                )
            );
        } else {
            //有答题记录
            $json['warn'] = update(
                array(
                    'table' => 'topic_answer_record_detail',
                    'field' => [
                        'state' => $bool ? 1 : 2,
                        'score' => $bool ? $paperLibraryMx['score'] : 0,
                        'reply' => json_encode($reply, 320),
                    ],
                    'where' => " id = '$record[id]'"
                )
            );
        }
        return json_encode($json, 320);
    }

    /**
     * 上一题或下一题
     */
    public function showNextTopic($isCommit = false)
    {
        $stid = $this->control['stid'];//答题人
        $topicId = $this->post('topicId');//试题ID
        $paperId = $this->post('paperId');//试卷ID
        $type = $this->post('type');//pre:上一题  next：下一题
        $paper = query('paper_library', " id = '$paperId'");//试卷信息
        $topic = query('topic_library_detail', " id = '$topicId'");//试题信息
        //开始答题记录
        $topicAnswerRecord = query('topic_answer_record', " paperId = '$paper[id]' and stid = '$stid'");
        $list = $this->post('list');//当前排序号
        $reply = $topic['topicType']=='多选题'?(array)json_decode($_POST['reply'],true):$this->post('reply');//回答
        if (empty($paper['id'])) {
            $this->resp['warn'] = '未找到此试卷';
        } elseif (self::total(array('table' => 'paper_people', "where" => " and orderId = '$paper[id]'")) <= 0) {
            $this->resp['warn'] = '您不属于此试卷的作答人员';
        } elseif (empty($topicAnswerRecord['id'])) {
            $this->resp['warn'] = '未找到开始答题记录';
        } elseif ($topicAnswerRecord['isCommit']) {
            $this->resp['warn'] = '您已作答完毕，请前往查看答题记录';
        } elseif ($paper['state'] != '已发布') {
            $this->resp['warn'] = '此试卷还未发布，不能作答';
        } elseif (empty($topic['id'])) {
            $this->resp['warn'] = '未找到此试题';
        } elseif (!$isCommit && (empty($type) || !in_array($type, ['pre', 'next']))) {
            $this->resp['warn'] = '未找到跳转类型';
        } elseif ($paper['answerType'] == '逐题答题' && $type == 'next' && $reply == '') {
            $this->resp['warn'] = '请先答完此题再做下一题';
        } else {
            //添加作答记录
            $this->setAnswer($paper, $topic, $reply, $topicAnswerRecord, $stid);
            $this->code = 1;
            $maxList = self::total(['table' => self::tableMx, 'where' => " and orderId = '$paperId'"]);//题目总数
            //重新调整排序
            if (empty($list) || $list <= 0 || !is_numeric($list)) {
                $list = 1;
            } elseif ($list >= $maxList) {
                $list = $maxList;
            }
            if ($type == 'next' && $list < $maxList) {
                $list++;
            } elseif ($type == 'pre' && $list > 1) {
                $list--;
            }
            $data['result'] = [
                'list' => $list,
                'id' => $paper['id'],
            ];
            $this->resp['data'] = $data;
        }
    }

    /**
     * 循环添加答题记录
     * @param $paperId
     * @param $topicId
     * @param $reply
     */
    public function setNullAnswer($paperId, $topicId, $reply)
    {
        $paper = query('paper_library', " id = '$paperId'");//试卷信息
        $topic = query('topic_library_detail', " id = '$topicId'");//试题信息
        //开始答题记录
        $topicAnswerRecord = query('topic_answer_record', " paperId = '$paper[id]' and stid = '" . self::$stid . "'");
        //添加作答记录
        $this->setAnswer($paper, $topic, $reply, $topicAnswerRecord, self::$stid);
    }

    /**
     * 逐题答题---交卷
     */
    public function commitPaper()
    {
        $stid = $this->control['stid'];//答题人
        $paperId = $this->post('paperId');//试卷ID
        $paper = query('paper_library', " id = '$paperId'");//试卷信息
        //开始答题记录
        $topicAnswerRecord = query('topic_answer_record', " paperId = '$paper[id]' and stid = '$stid'");
        if (empty($paper['id'])) {
            $this->resp['warn'] = '未找到此试卷';
        } elseif (self::total(array('table' => 'paper_people', "where" => " and orderId = '$paper[id]'")) <= 0) {
            $this->resp['warn'] = '您不属于此试卷的作答人员';
        } elseif ($paper['state'] != '已发布') {
            $this->resp['warn'] = '此试卷还未发布，不能作答';
        } elseif ($topicAnswerRecord['isCommit']) {
            $this->resp['warn'] = '您已提交了此试卷，无需重复提交';
        } else {
            //交卷时回答的那一题
            $this->showNextTopic(true);
            //检查未做的题目
            $this->checkNoAnswerTopic($paper, $stid);
            //计算得分
            $score = find(array('table' => 'topic_answer_record_detail', 'where' => " paperId = '$paperId' and stid = '$stid'", 'sum' => "score"));
            $this->resp['warn'] = update(array(
                'table' => 'topic_answer_record',
                'field' => [
                    'isCommit' => $paper['type'] == '考试' ? 1 : 0,
                    'commitTime' => $this->time,
                    'score' => $score,
                    'state' => $score >= $paper['passMark'] ? '合格' : '不合格',
                ],
                'where' => " id = '$topicAnswerRecord[id]'"
            ));
            if (in_array($this->resp['warn'], ["新增成功", "更新成功"])) {
                //添加日志
                $text = $this->control['name'] . "提交了答题试卷【{$paper['name']}】,id：【" . $paper['id'] . '】';
                $this->logText(["type" => self::page, "text" => $text]);
                $this->resp['warn'] = '交卷成功';
                $this->resp['data'] = '';
                //返回
                $this->code = 1;
            } else {
                $this->resp['warn'] = '交卷失败';
            }
        }
    }


    /**
     * 交卷是如果有未做的题目，则默认为错误答题
     */
    public function checkNoAnswerTopic($paper, $stid)
    {
        $topicArr = find(array('table' => 'paper_library_detail', 'where' => " orderId = '$paper[id]' order by list asc"));
        foreach ($topicArr['array'] as $array) {
            $record = query('topic_answer_record_detail', " paperId = '$paper[id]' and topicLibraryMxId = '$array[topicLibraryMxId]' and stid = '$stid'");
            if (empty($record['id'])) {
                //此题未做
                $this->setNullAnswer($paper['id'], $array['topicLibraryMxId'], '');
            }
        }
    }


    /**
     * 整卷提交
     */
    public function commitAllTopic()
    {
        $stid = $this->control['stid'];//答题人
        $paperId = $this->post('paperId');//试卷ID
        $paper = query('paper_library', " id = '$paperId'");//试卷信息
        //开始答题记录
        $topicAnswerRecord = query('topic_answer_record', " paperId = '$paper[id]' and stid = '$stid'");
        if (empty($paper['id'])) {
            $this->resp['warn'] = '未找到此试卷';
        } elseif (self::total(array('table' => 'paper_people', "where" => " and orderId = '$paper[id]'")) <= 0) {
            $this->resp['warn'] = '您不属于此试卷的作答人员';
        } elseif ($paper['state'] != '已发布') {
            $this->resp['warn'] = '此试卷还未发布，不能作答';
        } elseif ($topicAnswerRecord['isCommit']) {
            $this->resp['warn'] = '您已提交了此试卷，无需重复提交';
        } else {
            $replyArr = (array)json_decode($_POST['reply'],true);
            //此试卷所有题目
            $topicArr = find(array('table' => 'paper_library_detail', 'where' => " orderId = '$paper[id]' order by list asc"));
            foreach ($topicArr['array'] as $array) {
                foreach ($replyArr as $item){
                    if ($item['id'] == $array['topicLibraryMxId']){
                        $reply = $item['radio']??'';
                        break;
                    }
                }
                $this->setNullAnswer($paperId, $array['topicLibraryMxId'], $reply??'');
            }
            //计算得分
            $score = find(array('table' => 'topic_answer_record_detail', 'where' => " paperId = '$paperId' and stid = '$stid'", 'sum' => "score"));
            $endTime = strtotime($topicAnswerRecord['startTime']) + 60 * $paper['minute'];
            if ($endTime < time()) {
                $endTime = date('Y-m-d H:i:s', $endTime);
            } else {
                $endTime = $this->time;
            }
            $this->resp['warn'] = update(array(
                'table' => 'topic_answer_record',
                'field' => [
                    'isCommit' => $paper['type'] == '考试' ? 1 : 0,
                    'commitTime' => $endTime,
                    'score' => $score,
                    'state' => $score >= $paper['passMark'] ? '合格' : '不合格',
                ],
                'where' => " id = '$topicAnswerRecord[id]'"
            ));
            if (in_array($this->resp['warn'], ["新增成功", "更新成功"])) {
                //添加日志
                $text = $this->control['name'] . "提交了答题试卷【{$paper['name']}】,id：【" . $paper['id'] . '】';
                $this->logText(["type" => self::page, "text" => $text]);
                //返回
                $this->code = 1;
            }
        }
    }

    /**
     * 考试页面
     */
    public function testPaper()
    {
        $id = $this->post('id');//试卷ID
        $paper = query('paper_library', "id = '$id'");
        if (empty($paper['id'])) {
            $this->resp['warn'] = '未找到此试卷';
        } else {
            $stid = self::$stid;
            //试卷答题记录
            $topicAnswerRecord = query('topic_answer_record', " paperId = '$paper[id]' and stid = '$stid'");
            if (empty($topicAnswerRecord['id'])) {
                //总分
                $score = find(array('table' => self::tableMx, "where" => " orderId = '$paper[id]'", 'sum' => "score"));
                insert(array(
                    'table' => 'topic_answer_record',
                    'field' => [
                        'id' => self::getId(),
                        'paperId' => $paper['id'],
                        'stid' => $stid,
                        'startTime' => $this->time,
                        'jobId' => $this->control['jobId'],
                        'name' => $this->control['name'],
                        'totalScore' => $score,
                        'score' => 0,
                        'time' => $this->time
                    ]
                ));
                $endTime = date('Y-m-d H:i:s', time() + $paper['minute'] * 60);//交卷时间
            } else {
                $endTime = date('Y-m-d H:i:s', strtotime($topicAnswerRecord['startTime']) + $paper['minute'] * 60);//交卷时间
            }
            if (strtotime($endTime) <= time()){
                $this->resp['warn'] = '此试卷答题时间已结束';
            }else{
                $result = find(array('table' => self::tableMx, 'where' => " orderId = '$paper[id]' order by list asc,time asc"));
                if ($paper['answerType'] == '逐题答题') {
                    $maxList = count($result['array']);
                    if (empty($this->get('list')) || $this->get('list') <= 0 || !is_numeric($this->get('list'))) {
                        $list = 1;
                    } else {
                        $list = $this->get('list') > $maxList ? $maxList : $this->get('list');
                    }
                    $topicItem = [];
                    foreach ($result['array'] as $array) {
                        if ($array['list'] >= $list) {
                            //试题信息
                            $topic = query('topic_library_detail', " id = '$array[topicLibraryMxId]'");
                            //答题记录
                            $record = query('topic_answer_record_detail', " stid = '$stid' and paperId = '$paper[id]' and topicLibraryMxId = '$topic[id]'");

                            $choiceArr = json_decode(html_entity_decode($topic['item'],ENT_QUOTES), true);//选项
                            foreach ($choiceArr as $index => $val) {
                                $choiceArr[$index] = $this->itemWord[$index] . '. ' . $val;
                            }
                            $reply = (array)json_decode($record['reply'], true);
                            $topicItem[] = [
                                'id' => $topic['id'],
                                'title' => html_entity_decode($topic['title'],ENT_QUOTES),
                                'topicType' => $topic['topicType'],
                                'chooseItem' => $choiceArr,
                                'reply' => $topic['topicType']=='多选题'?$reply: ($reply[0]??'')
                            ];
                            break;
                        }
                    }
                }
                else {
                    $topicItem = [];
                    //整卷答题
                    foreach ($result['array'] as $array) {
                        $topic = query('topic_library_detail', " id = '$array[topicLibraryMxId]'");
                        $choiceArr = json_decode(html_entity_decode($topic['item'],ENT_QUOTES), true);//选项
                        foreach ($choiceArr as $index => $val) {
                            $choiceArr[$index] = $this->itemWord[$index] . '. ' . $val;
                        }
                        $topicItem[] = [
                            'id' => $topic['id'],
                            'paper_library_detail_id' => $array['id'],
                            'title' => html_entity_decode($topic['title'],ENT_QUOTES),
                            'topicType' => $topic['topicType'],
                            'chooseItem' => $choiceArr
                        ];

                    }
                }
                $num = self::total(array('table' => 'paper_library_detail', 'where' => " orderId = '$paper[id]'"));
                $data['result'] = [
                    'id' => $paper['id'],
                    'paperType' => $paper['answerType'],
                    'endTime' => (strtotime($endTime)-time())<0?0:strtotime($endTime)-time(),
                    'topicItem' => $topicItem,
                    'list' => $list ?? 1,//当前题目排序号
                    'topicNum' => $num
                ];
                $this->code = 1;
                $this->resp['data'] = $data;
            }

        }
    }

    /**
     * 答题说明
     */
    public function answerTip()
    {
        $id = $this->post('id');//试卷ID
        $paper = query('paper_library', "id = '$id'");
        if (empty($paper['id'])) {
            $this->resp['warn'] = '未找试卷';
        } elseif (time() >= strtotime($paper['endTime'])) {
            $this->resp['warn'] = '此试卷可答题时间已结束';
        } else {
            //总分
            $score = find(array('table' => 'paper_library_detail', "where" => " orderId = '$paper[id]'", 'sum' => "score"));
            //题目数量
            $num = self::total(array('table' => 'paper_library_detail', 'where' => " orderId = '$paper[id]'"));
            $data['result'] = array(
                "id" => $paper['id'],//答题记录ID
                'answerType'=>$paper['answerType'],
                "name" => $paper['name'],//试卷名称
                'score' => $score,
                'topicNum' => $num,
                'minute' => $paper['minute'],
                'startTime' => $paper['startTime'],
                'endTime' => $paper['endTime'],
            );
            //返回
            $this->code = 1;
            $this->resp['data'] = $data;
        }
    }


    /*待考试*/
    public function beTested()
    {
        //全等查询数组
        $equal = array(
            "b.state" => '已发布',//状态
        );
        //过滤掉已交卷的试卷
        $and = " and a.stid = '{$this->control['stid']}' and UNIX_TIMESTAMP(b.endTime) > UNIX_TIMESTAMP() and a.stid not in (select stid from topic_answer_record where paperId = b.id and isCommit = 1)";
        $data['result'] = [];
        //获取查询结果
        $where = search(array("=" => $equal)) . $and;
        $page = $this->page(array("table" => " paper_people as a join paper_library as b on a.orderId = b.id", 'field' => "b.*,a.stid as staffId", "where" => $where, "order" => " a.time desc"));
        foreach ($page['array'] as $array) {
            if (time() >= strtotime($array['startTime']) && time() <= strtotime($array['endTime'])) {
                $state = '进行中';
            } else {
                $state = '未开始';
            }
            $data['result'][] = array(
                "id" => $array['id'],//试卷ID
                "name" => $array['name'],//试卷名称
                "state" => $state,
                'startTime' => $array['startTime'],
                'endTime' => $array['endTime'],
            );
        }
        //返回
        $data['page'] = $page['para'];
        //返回
        $this->code = 1;
        $this->resp['data'] = $data;
    }

    /**
     * 已考试
     */
    public function tested()
    {
        //like查询数组
        $like = array(
            "b.name" => $this->post('keyword'),//试卷名称
        );
        //全等查询数组
        $equal = array(
            "b.state" => '已发布',//状态
            "a.state"=>$this->post('state')
        );
        //过滤掉已交卷的试卷
        $and = " and a.stid = '{$this->control['stid']}' and a.isCommit = 1";
        if ($this->post('chooseTime')){
            //时间筛选

        }

        $commitTime = $this->post('chooseTime');
        if (!$commitTime) {
            if ($this->post('startDate')) {
                $commitTime = $this->post('startDate');
            }
            if ($this->post('endDate')) {
                $commitTime .= empty($commitTime) ? $this->post('endDate') : ('~' . $this->post('endDate'));
            }
        }
        if ($commitTime) {
            $and .= $this->miniTimeComparison($commitTime, 'date', 'a.commitTime');
        }

        $orderBy=match ($this->sortOption[$this->post('sort')]){
            '创建时间升序'=>'b.time asc',
            '创建时间降序'=>'b.time desc',
            '考试时间升序'=>'a.startTime asc',
            default=>"a.startTime desc"
        };

        //获取查询结果
        $where = search(array("=" => $equal,'like'=>$like)) . $and;
        $page = $this->page(array("table" => " topic_answer_record as a join paper_library as b on a.paperId = b.id", 'field' => "a.*,b.name", "where" => $where, "order" => $orderBy));
        $data['result'] = [];
        //获取记录
        foreach ($page['array'] as $array) {
            //列表控件
            $second = strtotime($array['commitTime']) - strtotime($array['startTime']);
            $second = $second > 0 ? $second : 0;
            $data['result'][] = array(
                "id" => $array['id'],//答题记录ID
                "name" => $array['name'],//试卷名称
                'score' => $array['score'],
                'totalScore' => $array['totalScore'],
                'state' => $array['state'],
                'second' => $second,
                'commitTime' => date('m/d',strtotime($array['commitTime'])),//提交时间
            );
        }
        //返回
        $data['page'] = $page['para'];
        $data['sql'] = $page['sql'];
        //返回
        $this->code = 1;
        $this->resp['data'] = $data;
    }

    /**
     * 答题已完成界面
     */
    public function completePage()
    {
        $paperId = $this->post('id');
        $paper = query('paper_library', " id = '$paperId'");//试卷信息
        $where = '';
        if ($paper['type']=='考试'){
            $where=" and isCommit = 1";
        }
        $topic_answer_record = query('topic_answer_record', "paperId = '$paper[id]' and stid = '" . self::$stid . "'".$where);
        if (empty($topic_answer_record['id'])) {
            $this->resp['warn'] = '未找到答题记录';
        } else {
            //列表控件
            $second = strtotime($topic_answer_record['commitTime']) - strtotime($topic_answer_record['startTime']);
            $second = $second > 0 ? $second : 0;
            $this->code = 1;
            $totalNum = self::total(array('table' => 'paper_library_detail', 'where' => " orderId = '$paper[id]'"));
            $rightNum = self::total(array('table' => 'topic_answer_record_detail', 'where' => "orderId = '$topic_answer_record[id]' and state =1"));
            $data['result'] = [
                "id" => $topic_answer_record['id'],//答题记录ID
                "name" => $paper['name'],//试卷名称
                'score' => $topic_answer_record['score'],
                'totalScore' => $topic_answer_record['totalScore'],
                'state' => $topic_answer_record['state'],
                'second' => $second,
                'commitTime' => $topic_answer_record['commitTime'],//提交时间
                'rightNum' => $rightNum,
                'errorNum' => $totalNum - $rightNum,
                'totalNum' => $totalNum,
            ];
            $this->resp['data'] = $data;
        }
    }

    /**
     * 答题详情记录
     */
    public function paperRecord()
    {

        $id = $this->post('id');//答题记录ID
        //试卷答题记录
        $topicAnswerRecord = query('topic_answer_record', " id = '$id'");
        if (empty($topicAnswerRecord['id'])) {
            $this->resp['warn'] = '未找到此答题记录';
        } else {
            $paper = query('paper_library', "id = '$topicAnswerRecord[paperId]'");

            $result = find(array('table' => self::tableMx, 'where' => " orderId = '$paper[id]' order by list asc,time asc"));
            $topicItem = [];
            //整卷答题
            foreach ($result['array'] as $array) {
                $topic = query('topic_library_detail', " id = '$array[topicLibraryMxId]'");
                //答题记录
                $record = query('topic_answer_record_detail', " stid = '" . self::$stid . "' and orderId = '$topicAnswerRecord[id]' and topicLibraryMxId = '$topic[id]'");

                $choiceArr = json_decode($topic['item'], true);//选项
                foreach ($choiceArr as $index => $val) {
                    $choiceArr[$index] = $this->itemWord[$index] . '. ' . html_entity_decode($val,ENT_QUOTES);
                }
                //答案
                $answerArr = json_decode($topic['answer'], true);
                //回答
                $reply = (array)json_decode($record['reply'], true);
                $replyText = match ($topic['topicType']){
                    '多选题'=>$reply,
                    '主观题'=>$reply[0]??'',
                    default=>isset($reply[0])?(int)$reply[0]:''
                };
                $topicItem[] = [
                    'id' => $topic['id'],
                    'paper_library_detail_id' => $array['id'],
                    'title' => $topic['title'],
                    'topicType' => $topic['topicType'],
                    'chooseItem' => $choiceArr,
                    'reply' => $replyText,
                    'answer' => $topic['topicType']=='多选题'?$answerArr:$answerArr[0],
                    'state' => $record['state'] == 1 ? '正确' : '错误',
                ];
            }
            $second = strtotime($topicAnswerRecord['commitTime']) - strtotime($topicAnswerRecord['startTime']);
            $second = $second > 0 ? $second : 0;
            $data['result'] = [
                'paperId' => $paper['id'],
                'commitTime' => $topicAnswerRecord['commitTime'],
                'topicItem' => $topicItem,
                'score' => $topicAnswerRecord['score'],
                'totalScore' => $topicAnswerRecord['totalScore'],
                'second' => $second
            ];
            $this->code = 1;
            $this->resp['data'] = $data;
        }
    }
}
